<template>
  <div v-loading="loading">
    <el-form ref="form" :model="form" :rules="rules" label-width="120px" class="dataForm">

      <el-row>
        <el-col :span="12">
          <el-form-item :label="$t('IRR')" prop="irr">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.irr" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('是否进入综合榜单')" prop="isMonthlyFocus">
            <!-- <el-input v-model="form.isMonthlyFocus" :placeholder="$t('是否进入综合榜单 0 否 1是')" /> -->
            <el-select v-model="form.isMonthlyFocus" placeholder="请选择" @change="display">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>

        <el-col v-show="isDisplay" :span="12">
          <el-form-item :label="$t('综合榜单排名')" prop="ranking">
            <el-input v-model="form.ranking" :placeholder="$t('综合榜单排名')" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('是否进入分榜单')" prop="partMonthlyFocus">
            <!-- <el-input v-model="form.partMonthlyFocus" :placeholder="$t('是否进入分榜单 0 否 1 是')" /> -->
            <el-select v-model="form.partMonthlyFocus" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('分榜单如基金投向行业是否相符')" prop="isConform">
            <!-- <el-input v-model="form.isConform" :placeholder="$t('分榜单如基金投向行业是否相符 0 否 1 是')" /> -->
            <el-select v-model="form.isConform" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('控股相关行业上市公司数量')" prop="nolc">
            <el-input-number v-model="form.nolc" :min="0" :max="99999" />

            <!-- <el-input v-model="form.nolc" :placeholder="$t('控股相关行业上市公司数量')" /> -->
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item :label="$t('项目退出率')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.exitRatio" :min="0" :max="99999" />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item :label="$t('领头项目数量占比')" prop="irr">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.headRatio" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('完成工商变更数量')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.changeNumber" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('区政府/平台就项目落地签约')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.platformDeal" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('招商联席会已立项')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.attractDeal" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('平均irr')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.avgIrr" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('已投资钱塘区内项目基金数量')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.investFundNumber" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('返投倍数')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.backMultiple" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('DPI') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('DPI')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.dpi" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('总退出期年限')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.exitYear" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('已经过的退出期')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.exitDeadline" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('基金总存续期')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.fundRenewal" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('投资节奏') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('已投出金额')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.launchMoney" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('已经过的投资期年数')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.launchYear" :min="0" :max="99999" />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item :label="$t('基金总规模')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.launchFundScale" :min="0" :max="99999" />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item :label="$t('投资期年限')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.launchExpectYear" :min="0" :max="99999" />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item :label="$t('年管理费率')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.launchYearManageRatio" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('项目退出率') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('已退出项目投资成本')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.exitInvestCost" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('全部投资成本')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.exitTotalInvestCost" :min="0" :max="99999" />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item :label="$t('总退出期年限')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.exitTotalYear" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('已经过的退出期及延长期年限')">
            <!-- <el-input v-model="form.irr" :placeholder="$t('IRR')" /> -->
            <el-input-number v-model="form.exitLengthenYear" :min="0" :max="99999" />
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('累计管理人规模') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('管理人类型')">
            <dictSelect
              v-model="form.managerType"
              :clearable="true"
              dictionary="synthesize_manager_type"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('管理人规模')">
            <el-input v-model="form.managerScale" maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('管理人荣誉') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('投中榜单排名')">
            <el-input v-model="form.biddingRanking" maxlength="10" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('清科榜单排名')">
            <el-input v-model="form.qingkeRanking" maxlength="10" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('创始人(董事长/总经理)') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('学历')">
            <el-input v-model="form.educationBackground" maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('学校是否为985或全球100强')">
            <el-select v-model="form.isStrong" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('专业年限')">
            <el-input v-model="form.specialtyYears" maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('投资团队综合实力及专业匹配度') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('学历为博士的个数')" prop="drNumber">
            <el-input-number v-model="form.drNumber" :min="0" :max="99999" />

            <!-- <el-input v-model="form.drNumber" :placeholder="$t('最高学历为博士的投资经理个数')" /> -->
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('985院校或全球100强的投资经理数量')" prop="managerNumber">
            <el-input-number v-model="form.managerNumber" :min="0" :max="99999" />

            <!-- <el-input v-model="form.managerNumber" :placeholder="$t('最高学历毕业院校为985院校或全球100强的投资经理个数')" /> -->
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('10年以上与拟合作子基金主要投资领域或与投资相关的工作经验的投资经理个数')" prop="experienceNumber">
            <el-input-number v-model="form.experienceNumber" :min="0" :max="99999" />
            <!-- <el-input v-model="form.experienceNumber" :placeholder="$t('10年以上与拟合作子基金主要投资领域或与投资相关的工作经验的投资经理个数')" /> -->
          </el-form-item>
        </el-col>

      </el-row>

      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('风控能力') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('拥有CPA/CFA/FRM人数数量')">
            <el-input v-model="form.cpaCfaFrm" maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('拥有法律职业资格证书人数')">
            <el-input v-model="form.lawStatusNumber" maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('学校是否为985或全球100强风控人数')">
            <el-select v-model="form.isStrongRisk" placeholder="请选择">
              <el-option
                v-for="item in options"
                :key="item.value"
                :label="item.label"
                :value="item.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('工作经验十年以上的风控人数')">
            <el-input v-model="form.riskYearsNumber" maxlength="20" show-word-limit />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('团队跟投指标') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('是否具有跟投制度相关文件')">
            <dictSelect
              v-model="form.relevantDocument"
              :clearable="true"
              dictionary="sys_yes_no"
            />
          </el-form-item>
        </el-col>

        <el-col :span="12">
          <el-form-item :label="$t('团队跟头投拟合作子基金金额') + $t('金额单位')">
            <Money v-model="form.fundMoney" unit="w" />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('出资比例(%)')">
            <Ratio
              v-model="form.ratioOfInvestments"
              :precision="4"
              :controls="false"
              :min="0"
              :placeholder="$t('出资比例(%)')"
            />
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <div class="area-header">
          <span class="area-header-title">{{ $t('其他有限合伙人构成') }}</span>
        </div>
        <el-col :span="12">
          <el-form-item :label="$t('机构投资人占比(%)')">
            <Ratio
              v-model="form.orgInvestRatio"
              :precision="4"
              :controls="false"
              :min="0"
              :placeholder="$t('机构投资人占比(%)')"
            />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('上榜单投资者数量')">
            <el-input v-model="form.upInvestNumber" maxlength="100" show-word-limit />
          </el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item :label="$t('是否有浙江省及杭州市级产业基金出资')">
            <dictSelect
              v-model="form.zhejiangHangzhou"
              :clearable="true"
              dictionary="sys_yes_no"
            />
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>
    <div slot="footer" class="dialog-footer" style="text-align: center;margin-top: 10px;">
      <!--保存 取消按钮-->
      <save-btn has-permi="system:index" :cancel-show="false" />
    </div>
  </div>
</template>

<script>
    import { saveGpEvaluationIndex, getGpEvaluationIndex } from '@/api/fund/gp/gpEvaluation/gpEvaluationIndex'
    export default {
        data() {
            return {
                // 表单参数
                form: {},
                options: [
                   { value: '0', label: '否' },
                   { value: '1', label: '是' }
                ],
                fundId: this.$route.query.id,
                // 遮罩层
                loading: false,
                isDisplay: false,
                // 表单校验
                rules: {
                }
            }
        },
        created() {
          this.init(this.fundId)
        },
        methods: {
            // 初始化数据
            init(data) {
                this.loading = true
                if (data != null) {
                    getGpEvaluationIndex(data).then(response => {
                      if (response.data) {
                           this.form = response.data
                           this.display(this.form.isMonthlyFocus)
                      } else {
                          this.reset()
                      }
                        this.loading = false
                    })
                } else {
                    this.reset()
                    this.loading = false
                }
            },
            // 表单重置
            reset() {
                this.form = {
                    id: undefined,
                    irr: undefined,
                    isMonthlyFocus: '0',
                    ranking: undefined,
                    partMonthlyFocus: undefined,
                    isConform: undefined,
                    nolc: 0,
                    drNumber: 0,
                    managerNumber: 0,
                    experienceNumber: 0,
                    funtId: undefined
                }
                this.resetForm('form')
            },
            // 取消按钮
            cancel() {
                this.$parent.$parent.formOpen = false
                this.$parent.$parent.reset()
            },
            // 关闭form页面
            closeForm() {
                // 关闭form页面遮罩层
                this.loading = false
                // 关闭form页面
                if (this.$parent.$parent.formOpen !== undefined) {
                  this.$parent.$parent.formOpen = false
                }
                // 刷新list页面
                if (this.$parent.$parent.getList !== undefined) {
                  this.$parent.$parent.getList()
                }
            },
            /** 提交按钮 */
            submitForm() {
                this.$refs['form'].validate(valid => {
                    if (valid) {
                        this.loading = true
                        this.form.fundId = this.fundId
                        saveGpEvaluationIndex(this.form).then(response => {
                            if (response.code === 200) {
                                this.msgSuccess(this.$t('保存成功'))
                                this.init(this.fundId)
                                this.closeForm()
                            } else {
                                this.msgError(response.msg)
                            }
                            this.loading = false
                        })
                    } else {
                       this.locationError(document)
                    }
                })
           },
           display(val) {
              this.isDisplay = (val === '1')
           }

        }

    }
</script>
